package com.homwork;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class HashMap源码 {
    public static void main(String[] args) {
        HashMap<Integer, String> mp = new HashMap<>();
        mp.put(1,"a");
        mp.put(2,"b");
        mp.put(3,"c");
        mp.put(4,"d");
        mp.put(5,"e");


        //1.遍历方式1:键找值
        Set<Integer> s  = mp.keySet();
        for(Integer i : s)
        {
            System.out.print(i + "==> " + mp.get(i) + " ");
        }
        System.out.println();


        //2.键值对
        for(Map.Entry<Integer,String> m : mp.entrySet())
        {
            System.out.print(m.getKey() + "=>" + m.getValue());
        }

        //3.Lambda
        mp.forEach((i,s_) -> System.out.println(i + "==>" + s_));
    }
}
